﻿
/*向量容器，动态数组
* 2012 - 8 - 22 westice
* myVector.h
*/
#pragma once
#include <stdio.h>
#include "myTools.h"


#define DEFAULT_MYVECTOR_CAPACITY 5   //默认数组容量

typedef struct myVectorNodeType{
	//动态数组节点
	void* bindDataPtr;
	int testValue;
}myVectorNode;

typedef struct myVectorType{
	//动态数组类型
	int length;
	int maxCapacity;
	myVectorNode* vectorDataPtr;

}myVector;


//动态数组操作函数
myVector* createMyVector(int capacity);
void releaseMyVector(myVector* vec);

void myVectorAppendItem(myVector* vec,myVectorNode* item);
void myVectorAppendVector(myVector* vec,myVector* vec1);
void myVectorInsertItemAt(myVector* vec,myVectorNode* item,int index);
void myVectorReplaceItemAt(myVector* vec,myVectorNode* item,int index);
void myVectorSwap(myVector* vec,int index,int index1);
void myVectorRemoveItemAt(myVector* vec,int index);
void myVectorRemoveAll(myVector* vec);

//将vec1 的range1部分 拷贝到 vec 的 pos位置
//无重叠区域拷贝
void myVectorCopy(myVector* vec,int pos,myVector* vec1,myRange range1);

//有重叠区域拷贝
void myVectorCopyHasOverLap(myVector* vec,int pos,myVector* vec1,myRange range1);

myVectorNode* myVectorAt(myVector* vec,int index);
int myVectorLength(myVector* vec);
void* myVectorBindDataPtr(myVector* vec);

void myVectorPrintAt(myVector* vec,int index);
void myVectorTestPrint(myVector* vec);

